<?php
	if($product_information->num_rows()<=0){
		redirect("account/products");
	}
	foreach($product_information->result() as $row){
		$product_name=$row->name;
		//$use_brand_id=$row->use_brand_id;
		$use_category_id=$row->use_category_id;
		$use_product_function_id=$row->use_product_function_id;
		$price=$row->price;
		$desc=$row->description;
		$more_info=$row->more_info;
	}
?>
<div class="login">
          <div class="wrap">
				<ul class="breadcrumb breadcrumb__t"><a class="home" href="<?php echo base_url();?>">Home</a>  / <?php echo $this -> mod_account -> get_logged_in_user_info() -> email;?> </ul>
				<div class="section group">
					<?php $this -> load -> view(F_MASTER . "dashboard_account"); ?>
				   
				    <div class="cont span_2_of_about">
				    	
				    		<!--<div class="alert alert-error"><?php echo validation_errors(); ?></div>-->
					
				
	           		<h3>Update product</h3>
	           		<form class="form-horizontal" method="post" action="<?php echo base_url();?>account/update-product/<?php echo $this->uri->segment(3);?>" enctype="multipart/form-data">	
		<div class="row">
                <div class="col-lg-12">
                	<?php
					//$this->load->view('help/notifications');
                    ?>
                    <div class="panel panel-primary">
                        <div class="panel-heading">
                          Product Information
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body form-horizontal">
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="brand">Brand <span style="color: red;">*</span></label>
								<div class="col-md-6">
									<select name="brand" class="form-control">
										<option value="0">--Please Select--</option>
										<?php
											foreach($brands->result() as $brand){
												$brand_id=$brand->brand_id;
												$brand_name=$brand->name;
												if($use_brand_id==$brand_id){
										?>
													<option value="<?php echo $brand_id;?>" selected="selected"><?php echo $brand_name;?></option>
										<?php
												}else{
										?>
													<option value="<?php echo $brand_id;?>"><?php echo $brand_name;?></option>
										<?php
												}
										?>
												
										<?php
											}
										?>
										
									</select>
									<span class="help-block"><?php echo form_error('brand'); ?></span>
								</div>
							</div>
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="category">Category <span style="color: red;">*</span></label>
								<div class="col-md-6">
									<select name="category" class="form-control">
										<option value="0">--Please Select--</option>
										<?php
											foreach($categories->result() as $category){
												$category_id=$category->category_id;
												$category_name=$category->name;
												if($use_category_id==$category_id){
										?>
													<option value="<?php echo $category_id;?>" selected="selected"><?php echo $category_name;?></option>
										<?php
												}else{
										?>
													<option value="<?php echo $category_id;?>"><?php echo $category_name;?></option>
										<?php
												}
										
											}
										?>
									</select>
									<span class="help-block"><?php echo form_error('category'); ?></span>
								</div>
							</div>
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="name">Name <span style="color: red;">*</span></label>
								<div class="col-md-6">
									<input id="name" name="name" placeholder="" class="form-control input-md" type="text" required="required" value="<?php echo str_replace("_", " ", $product_name);?>">
									<span class="help-block"><?php echo form_error('name'); ?></span>
								</div>
							</div>
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="price">Price <span style="color: red;">*</span></label>
								<div class="col-md-6">
									<input id="name" name="price" placeholder="" class="form-control input-md" type="text" required="required" value="<?php echo $price;?>">
									<span class="help-block"><?php echo form_error('price'); ?></span>
								</div>
							</div>
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="description">Description</label>
								<div class="col-md-8">
									<textarea class="form-control" rows="8" name="description"><?php echo $desc;?></textarea>
								</div>
							</div>
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="more_info">More Information</label>
								<div class="col-md-8">
									<textarea class="form-control" rows="8" name="more_info"><?php echo $more_info;?></textarea>
								</div>
							</div>
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="product_for">Post product for <span style="color: red;">*</span></label>
								<div class="col-md-6">
									<select name="product_for" class="form-control">
										<?php
											foreach($product_functions->result() as $pro_function){
												$pro_function_id=$pro_function->product_function_id;
												$pro_function_name=$pro_function->name;
												if($use_product_function_id==$pro_function_id){
										?>
													<option value="<?php echo $pro_function_id;?>" selected="selected"><?php echo str_replace('_', ' ', $pro_function_name);?></option>
										<?php
												}else{
										?>
													<option value="<?php echo $pro_function_id;?>"><?php echo str_replace('_', ' ', $pro_function_name);?></option>
										<?php
												}
										
											}
										?>
									</select>
									<span class="help-block"><?php echo form_error('product_for'); ?></span>
								</div>
							</div>
							
							<!-- Text input-->
							<div class="form-group">
								<label class="col-md-4 control-label" for="userfile">Upload image <span style="color: red;">*</span></label>
								<div class="col-md-6">
									
									<div class="form-group input-group">
											<input id="userfile" name="userfile[]" placeholder="" class="form-control input-md"  type="file">
										   	<span class="input-group-btn"><button type="button" class="btn btn-default btn-add">+</button></span>
									</div>
									
									
									<span class="help-block"><?php echo form_error('userfile'); ?></span>
								</div>
							</div>
							
							
											
                         </div>
                    </div>
                </div>
           </div>
           
           
           
           <div class="row"><!-- Button (Double) -->
							
                <div class="col-lg-12">
                    	<div class="form-group">
								<label class="col-md-4 control-label" for="submit"></label>
								<div class="col-md-8">
									<button id="submit" name="submit" class="btn btn-success" type="submit">
										<i class="glyphicon glyphicon-ok"></i>
										<?php echo $this -> lang -> line('button_update'); ?>
									</button>
									<button id="clear" name="clear" class="btn btn-warning" type="button" onclick="goBack()">
										<i class="glyphicon glyphicon-remove"></i>
										<?php echo $this -> lang -> line('button_cancel'); ?>
									</button>
								</div>
							</div>
                </div>
                <!-- /.col-lg-12 -->
            </div>
</form>                   	
			    
				
				<div class="clear"></div>
			
					</div>
           </div>
		   <div class="clear"></div>	
		  </div>
	</div>	
   




